package multidraw.model.server;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import multidraw.model.CentralCanvasObserver;
import multidraw.model.Shape;
import multidraw.model.commands.Command;
import multidraw.tools.ToolInfo;
import multidraw.util.SyncToolReport;

/**
 * This interface is central in this project. It provides  
 * @author Cuong Bui
 * @version 1.0
 * @note Proxy of the CanvasServer (at the client side)
 */
public interface CanvasModel extends Remote {

	/**
	 * Get the data (list of shapes) from the central server.
	 * @return Returns the list of shapes
	 * @throws RemoteException Indicates any network problem
	 */
	//public List<Shape> getData() throws RemoteException;
	
	/**
	 * Make the model selects the object at the coord. (X, Y). 
	 * @param X X axis value.
	 * @param Y Y axis value.
	 * @throws RemoteException
	 */
	//public void selectObject(int X, int Y) throws RemoteException;
	
	/**
	 * Add a shape to the model.
	 * @param s The shape to add.
	 * @throws RemoteException Indicates any network problem.
	 */
	//public void addShape(Shape s) throws RemoteException;
	
	/**
	 * Attach an observer to the model. Usually an observer is a local model 
	 * cache. 
	 * @param o The observer to be attached.
	 * @throws RemoteException Indicates any network problem.
	 * @return 0 for success
	 *         -1 if trying to register with already existing username
	 *         -2 if trying to log on again with nonexistent username
	 */
	public int attachObserver(CentralCanvasObserver o) throws RemoteException;
	
	public void detachObserver(CentralCanvasObserver o) throws RemoteException;
	
	/**
	 * Apply a command to the model and propagate it to all the current 
	 * observers.
	 * @param command is the command to be applied.
	 * @throws RemoteException Indicates network problems.
	 */
	public void applyCommand(Command command) throws RemoteException;
	
	public List<Command> getUpdates(String clientID) throws RemoteException;
	
	public CoreData getCoreData(String sessionID) throws RemoteException;
	
	/**
	 * Create a session in the server.
	 * @param clientID
	 * @return The sessionID of the created session.
	 * @throws RemoteException
	 */
	public String createSession(String clientID) throws RemoteException;
	
	/**
	 * Join a session with owner name.
	 * @param ownerID
	 * @return The sessionID of this session.
	 * @throws RemoteException
	 */
	public String joinSession(String clientID, String ownerID) throws RemoteException;
	
	public Vector<String> getClients(String sessionID) throws RemoteException;
	
	public Hashtable<String, Role> getUserRoles(String sessionID) throws RemoteException;
	
	public SyncToolReport syncToolList(String sessionID, ArrayList<ToolInfo> clientToolList) throws RemoteException;
	
	
}
